package com.agile.leetcode.url;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/7/8 16:56
 */
public class URLConnectionReader {
    public static void main(String[] args) throws IOException {
        String path = "http://www.baidu.com";
        URL url = new URL(path);
        URLConnection connection = url.openConnection();
        BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
        String content;
        while ((content = br.readLine()) != null) {
            System.out.println(content);
        }
    }
}
